﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Satates.WaterCupState;

namespace Operators.WaterCupOperators
{
    public class Empty_2to1:iOperator
    {

        public int getOperatorNumber()
        {
            return 6;
        }
        public WaterCupState execute(WaterCupState s)
        {

            int aux1 = min(3, s.getCapacity1() + s.getCapacity2());
            int aux2 = 0;
            if (s.getCapacity2() < 3 - s.getCapacity1()) aux2 = 0;
            else aux2 = Math.Abs(3 - (s.getCapacity1() + s.getCapacity2()));
            WaterCupState s2 = new WaterCupState(aux1, aux2);
            return s2;

        }
        public bool available(WaterCupState s)
        {
            if (s.getCapacity2() > 0 && s.getCapacity1() < 3)
                return true;
            else return false;
        }
        public int min(int a, int b)
        {
            if (a < b) return a; else return b;
        }
        public override string ToString()
        {
            return "Filling first using second cup";
        }
        public object Clone()
        {
            return this.MemberwiseClone();
        }
        public Common.Template execute(Common.Template t)
        {
            WaterCupState s = (WaterCupState)t;
            int aux1 = min(3, s.getCapacity1() + s.getCapacity2());
            int aux2 = 0;
            if (s.getCapacity2() < 3 - s.getCapacity1()) aux2 = 0;
            else aux2 = Math.Abs(3 - (s.getCapacity1() + s.getCapacity2()));
            WaterCupState s2 = new WaterCupState(aux1, aux2);
            return s2;
        }

        public bool available(Common.Template t)
        {
            WaterCupState s = (WaterCupState)t;
            if (s.getCapacity2() > 0 && s.getCapacity1() < 3)
                return true;
            else return false;
        }
    }
}
